/**
 * 
 */
package com.asset.salesforce.controller.pages;

import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.asset.salesforce.domain.Employee;
import com.asset.salesforce.service.CalendarService;
import com.asset.salesforce.service.CompanyService;
import com.asset.salesforce.service.EmployeeService;

// TODO: Auto-generated Javadoc
/**
 * The Class CalendarController.
 *
 * @author Hisham
 */
@Controller
public class CalendarController {
	
	/** The calendar service. */
	@Autowired
	private CalendarService calendarService;
	
	/** The company service. */
	@Autowired
	private CompanyService companyService;
	
	/** The employee service. */
	@Autowired
	private EmployeeService employeeService;
	
	/**
	 * Gets the calendar page.
	 *
	 * @param session the session
	 * @param model the model
	 * @param response the response
	 * @return the calendar page
	 */
	@RequestMapping(value = "/calendar", method = RequestMethod.GET)
	public String getCalendarPage(HttpSession session, Model model,HttpServletResponse response) {
		if (null == session.getAttribute("userDetails")) {return "redirect:login";}
		Employee employee = (Employee)session.getAttribute("userDetails");
		List<Employee>employees = employeeService.getAllCompanyEmployess(employee.getCompany().getCompanyName());
		model.addAttribute("employees",employees);
		return "viewCalendarPage";
	}
}
